package cn.mulanbay.api.system.factory;

import cn.mulanbay.api.system.bean.RemoteWxAuthAccessUrl;
import cn.mulanbay.api.system.service.RemotePaymentService;
import cn.mulanbay.common.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * 角色服务降级处理
 *
 * @author fenghong
 */
public class RemotePaymentFallbackFactory implements FallbackFactory<RemotePaymentService> {

    private static final Logger log = LoggerFactory.getLogger(RemotePaymentFallbackFactory.class);

    @Override
    public RemotePaymentService create(Throwable throwable) {

        log.error("支付服务调用失败:{}", throwable.getMessage());

        return new RemotePaymentService() {

            @Override
            public R<RemoteWxAuthAccessUrl> authAccessUrl() {
                return R.fail("获取微信授权地址失败:" + throwable.getMessage());

            }

        };
    }
}
